package com.saber.pattern.singleton;

/**
 * 由于jvm特性，可能会出现instance为null的情况。
 * @author saber
 * @version 1.0
 * @Package: com.saber.pattern.singleton
 * @Date: 2017/4/10
 * @Time: 13:34
 */
public class SingletonSync {

    private SingletonSync instance = null;

    private SingletonSync() {
    }

    public SingletonSync getInstance() {
        if (null == instance) {
            synchronized (SingletonSync.class) {
                if (null == instance) {
                    instance = new SingletonSync();
                }
            }
        }
        return instance;
    }
}
